package view.layers;

import javax.microedition.lcdui.Graphics;
import model.structs.Point;

/**
 * A Layer is an abstract class representing a visual element of a game. Each Layer has
 * position (in terms of the upper-left corner of its visual bounds), width, height. A custom
 * Layer class was created for the Drug Wars system because it is impossible to subclass
 * the javax.microedition.lcdui.game.Layer class directly.
 *
 * @author rhaq
 * @version 1.00 2009-05-07 Initial submission.
 */
public abstract class Layer
{
	/** The reference position used when placing any object to a layer. */
	protected static final int RELATIVE_POSITION = Graphics.TOP | Graphics.LEFT;

	/** The current x,y coordinates of the layer. */
	protected Point current;

	/**
	 * Retrieves the 
	 * @return the current.
	 */
	public Point getCurrent()
	{
		return current;
	}


	/** The maximum x,y coordinates of the layer. */
	protected Point maximum;

	/** The minimum x,y coordinates of the layer. */
	protected Point minimum;



	/**
	 * Creates a Layer with the specified width and height.
	 * @param w The width of this layer.
	 * @param h The height of this layer.
	 */
	protected Layer(int w, int h)
	{
		current = new Point();
	}


	/**
	 * Determines if the layer's focus position is edged to the bottom of the screen.
	 * @return true if the layer is edged to the bottom of the screen, false otherwise.
	 */
	public abstract boolean isBottomEdged();


	/**
	 * Determines if the layer's focus position is edged to the left of the screen.
	 * @return true if the layer is edged to the left of the screen, false otherwise.
	 */
	public abstract boolean isLeftEdged();


	/**
	 * Determines if the layer's focus position is edged to the right of the screen.
	 * @return true if the layer is edged to the right of the screen, false otherwise.
	 */
	public abstract boolean isRightEdged();


	/**
	 * Determines if the layer's focus position is edged to the top of the screen.
	 * @return true if the layer is edged to the top of the screen, false otherwise.
	 */
	public abstract boolean isTopEdged();


	/**
	 * Performs a move-down operation on this layer.
	 */
	public abstract void moveDown();


	/**
	 * Performs a move-left operation on this layer.
	 */
	public abstract void moveLeft();


	/**
	 * Performs a move-right operation on this layer.
	 */
	public abstract void moveRight();


	/**
	 * Performs a move-up operation on this layer.
	 */
	public abstract void moveUp();


	/**
	 * Paints this layer using its current x and y coordinates.
	 * @param g The interface allowing 2D geometric rendering capability.
	 */
	public abstract void paint(Graphics g);


	/**
	 * Sets the currentX to the specified value.
	 * @param currentX The currentX to set.
	 */
	public final void setCurrentX(int currentX)
	{
		this.current.setX(currentX);
	}


	/**
	 * Sets the currentY to the specified value.
	 * @param currentY The currentY to set.
	 */
	public final void setCurrentY(int currentY)
	{
		this.current.setY(currentY);
	}
}